﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MoveCamera : MonoBehaviour {

	public float sensitivityMouse = 2f;
	public float sensitivetyKeyBoard = 0.1f;
	public float sensitivetyMouseWheel = 10f;

	void Update() {

		//鼠标左键按住拖动控制摄像机旋转
		if (Input.GetMouseButton(0)) {
			transform.Rotate(-Input.GetAxis("Mouse Y") * sensitivityMouse, Input.GetAxis("Mouse X") * sensitivityMouse, 0);
		}
		//鼠标滚轮控制摄像机前进/后退
		if (Input.GetAxis("Mouse ScrollWheel") != 0) {
			transform.Translate(0, 0, Input.GetAxis("Mouse ScrollWheel") * sensitivetyMouseWheel);
		}

		//键盘控制侧向移动
		if (Input.GetAxis("Horizontal") != 0) {
			transform.Translate(Input.GetAxis("Horizontal") * sensitivetyKeyBoard, 0, 0);
		}
		if (Input.GetAxis("Vertical") != 0) {
			transform.Translate(0, Input.GetAxis("Vertical") * sensitivetyKeyBoard, 0);
		}

	}

	public void ResetView() {
		gameObject.transform.position = new Vector3(7, 7, 7);
		gameObject.transform.rotation = Quaternion.Euler(new Vector3(30, -135, 0));
	}

}
